var nodemailer = require("nodemailer");

exports.sendMail = function(query, callback){
// create reusable transporter object using SMTP transport
var transData = {
	service:  query.senderHoster+"",
	auth: {
		user: query.senderEmail,
		pass: query.senderPWD
	}
};
console.log("transData ",transData);
var transporter = nodemailer.createTransport(transData);

// NB! No need to recreate the transporter object. You can use
// the same transporter object for all e-mails

// setup e-mail data with unicode symbols
var mailOptions = {
    from: '<'+query.senderEmail+'>', // sender address
    to: query.receiver+"@"+query.receiveHoster, // list of receivers
    subject:query.header, // Subject line
 //   text: 'Hello ', // plaintext body
    html: query.content //img0.bdstatic.com/img/image/shouye/chongwu0323.jpg">看到了吧。</div>据说<a href="www.baidu.com" target="_blank">这样写</a>和<attr style="color:blue;"><strong>这样写</strong></attr>是不一样的。www.baidu.com' // html body
};
console.log("mailOptions ",mailOptions);
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
	if(error){
		console.log(error);
	
		callback("error");
	}else{
		console.log('Message sent: ' + info.response);
		callback("success");
	}
});
}